<?php

 /**
  * @package JooS
  * @subpackage Syntax
  */

  require_once "JooS/Syntax/Complex.php";
  
  require_once "JooS/Syntax/Complex/Transition/Interface.php";

  abstract class JooS_Syntax_Complex_Transition extends JooS_Syntax_Complex implements JooS_Syntax_Complex_Transition_Interface {
    /**
     * @param int $num
     * @return JooS_Syntax_Abstract
     */
    public function getRule($num = null) {
      $rule = parent::getRule();
      return is_null($rule) ? null : $rule->getRule($num);
    }

    /**
     * @param int $num
     * @return string
     */
    public function getParsedValue($num = null) {
      $rule = parent::getRule();
      return is_null($rule) ? null : $rule->getParsedValue($num);
    }

    /**
     * @return string
     */
    public function compile() {
      return parent::getRule()
        ->compileSyntax();
    }

    public function compileSyntax() {
      if (parent::getRule() == null) {
        $this->setRule($this->createRule());
      }
      return parent::compileSyntax();
    }
  }
